$(function() {
	
	
	//信息遍历
	heardLook(function(data) {
		$('#cardsEdit').html(template('cardsEditTemplate', data));
		$('#msgSeven').on('tap', function() {
			mui.toast('不可修改！')
		});
	});

	//信息修改
	$('.user-btn').on('tap', function() {
		var msgOne = $('#msgOne').val();
		var msgTwo = $('#msgTwo').val();
		var msgThree = $('#msgThree').val();
		var msgFour = $('#msgFour').val();
		var msgFive = $('#msgFive').val();
		var msgSix = $('#msgSix').val();
		var msgSeven = $('#msgSeven').html();
		var msgEight = $('#msgSeven').val();
		personRevise({
			userName: msgOne,
			userUnit: msgTwo,
			userTitle: msgThree,
			userQq: msgFour,
			userPostbox: msgFive,
			userTrd: msgSix,
			userTel: msgSeven,
			userPhone: msgEight,
			token: getCookieValue("token")
		}, function(data) {
			console.log(getCookieValue("token"))
			console.log(data)
			if(data == 0) {
				mui.toast('修改成功')
			} else {
				window.location.href = 'l-userlogin.html';
			}

		});
	});

});

//遍历
//var personLook = function(callback) {
//	$.ajax({
//		type: "get",
//		url: window.address + "/user/findBayUserUuid",
//		xhrFields: {
//			withCredentials: true
//		},
//		crossDomain: true,
//		data: {
//			"userUuid":CD.geturl().business
//		},
//		dataType: "json",
//		success: function(data) {
//			console.log(data, 22222)
//			callback && callback(data);
//		}
//	});
//}

//修改
var personRevise = function(params, callback) {
	$.ajax({
		type: "get",
		url: window.address + "/user/userUpdate",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: params,
		dataType: "json",
		success: function(data) {
			//console.log(data, 11111)
			callback && callback(data);
		}
	});
};

//个人信息
var heardLook = function(callback) {
	$.ajax({
		type: "post",
		cache: false,
		traditional: true,
		dataType: "json",
		url: window.address + "/user/findBayUserUuid",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		data: {
			"userUuid": CD.geturl().business
		},
		success: function(data) {
			//console.log(data,88);
			callback && callback(data);
		}
	});
}